﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="Scripts/jquery-3.3.1.min.js"></script>
    <script src="Scripts/jquery.signalR-2.2.2.js"></script>
    <script src="/signalr/hubs" type="text/javascript"></script>
</head>
<body>
    <input type="text" id="userName" />
    <input type="button" value="click" id="btnLogin"/>
    <ul id="list"></ul>
    <script>
        $.connection.hub.start().done(function () {
            alert("done");
        }).fail(function () {
            alert("fail");
            });

        $("#btnLogin").click(function () {
            var userName = $("#userName").val();
            $.connection.onlineUsersHub.server.login(userName);
        });

        $.connection.onlineUsersHub.client.onOnlineUserStatusChange = function (msg) {
            $("#list").empty();
            for (var item in msg) {
                $("<li>" + item + "(" + msg[item] + ")</li>").appendTo($("#list"));
            }
        };
 
    </script>
</body>
</html>